<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="netville.config.ConfigUtil"%>
<%@ page import="com.se.utils.*"%>
<%@ page import="com.se.model.*"%>
<%@ page import="java.net.URLDecoder"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Map"%>
<%@ taglib prefix="sep" uri="/tags/sep"%>
<%
	String errcode = (String) request.getAttribute("ERRCODE");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<link type="text/css" href="<sep:config key='server.config.doc-root'/>/css/login.css" rel="stylesheet">
<title>삼정펄프 로그인</title>

<title><sep:config key='server.config.service-title' /></title>
<script type="text/javascript">
	var cook = "";
	// alert(document.cookie);
<%if (errcode != null && "1".equals(errcode)) {
				out.println("alert('사번 또는 비밀번호를 확인해 주세요.')");
			}%>
	function goLogin(){
		
		var loginForm = document.forms.loginForm;
		loginForm.action = "<sep:config key='server.config.context-root'/>/login/loginExec.do";
		loginForm.submit();
	}

	function confirmSave(checkbox){
		
		if (loginForm.idcheck.checked) {
			saveLogin(loginForm.user_id.value);
		} else {
			saveLogin("");
		}
	}

	function setsave(name, value, expiredays){
		
		var today = new Date();
		today.setDate(today.getDate() + expiredays);
		document.cookie = name + "=" + escape(value) + "; path=/; expires=" + today.toGMTString() + ";";
	}

	function saveLogin(user_id){
		if (user_id != "") {
			// userid 쿠키에 id 값을 180일간 저장
			setsave("mstrid", user_id, 180);
		} else {
			// userid 쿠키 삭제
			setsave("mstrid", user_id, -1);
		}
	}

	function getLogin(){
		// userid 쿠키에서 id 값을 가져온다.
		
		cook = document.cookie + ";";
		var setid = cook.split(';');
		
		for ( var i = 0; i < setid.length; i++) {
			if (setid[i].indexOf("mstrid=", 0) != "-1") {
				var id = UserTrim(setid[i].replace("mstrid=", ""));
				document.loginForm.user_id.value = id;
				document.loginForm.idcheck.checked = true;
				document.loginForm['user_pw'].focus();
			}
		}
		
	}

	function UserTrim(str){
		str = str.replace(/^\s*/, '').replace(/\s*$/, '');
		return str;
	}

	function formEnter(key){
		
		if (event.keyCode == 13) {
			if (key == 'password') goLogin();
			
		}
	}
</script>
</head>

<style>
html {
	overflow-x: auto;
	overflow-y: auto;
}
</style>
<body onLoad="getLogin()">
	<form name="loginForm" id="loginForm" method="post">
	
	 <div id="login_wrap">
		<div id="login">
			<div id="checkAgreeW">
				<div id="checkAgree">
					<span class="inputArea"><input type="text" class="text" name="user_id" id="user_id" style="width:110px;" value="" /></span>
					<span class="inputArea"><input type="password" class="text" name="user_pw" id="user_pw" style="width:110px;" value="" /></span>
				</div>
				<input type="image" src="<sep:config key='server.config.doc-root'/>/images/btn_login.gif" class="login_btn" style="cursor: pointer" onclick="goLogin();" alt="로그인">
				<span class="checkbox"><input type="checkbox" id="idcheck" name="idcheck" value=""  onClick="confirmSave(this)" /> 아이디저장</span>
			</div>
		</div>
		<div id="footer">
			<span class="cpoy_txt">
				임직원을 위한 시스템으로서 인가된 분만 사용할 수 있습니다.<br/>
				불법으로 사용시에는 법적 제재를 받을 수 있습니다.
			</span>
			<p class="copyright">COPYRIGHT 1974-2013 SAMJUNG PULP. ALL RIGHT RESERVED.</p>
		</div>
    </div>
		
	</form>
</body>
</html>
